package com.demo.rydemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author ry
 * @Description  跨域配置 https://blog.csdn.net/Jarvenman/article/details/97641966
 * 这么配置后  自定义拦截器 好像就没作用了！！！
 * https://www.cnblogs.com/yhcjhun/p/10879690.html
 * @Date 2020/8/6 11:30
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //设置允许跨域的路径
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("*")
                .allowedHeaders("*")
                //跨域允许时间
                .maxAge(3600);
    }
}
